﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Reflection;
using System.IO;
using System.Windows.Forms;
using System.Media;

namespace Resources
{
	public class ResourceManager
	{
		public static void Init()
		{
			// we don't need any explicit in here right now
			// because the static constructor will fire before
			// this is called, achieving the initialization
		}

		Assembly resourceAssembly;

		Image torchlightButtonNormal;
		Image torchlightButtonHighlight;
		Image torchlightButtonClickHighlight;
		SoundPlayer healDrinkSound;

		static ResourceManager current;
		public static ResourceManager Current
		{
			get
			{
				return current;
			}
		}

		static ResourceManager()
		{
			current = new ResourceManager();
		}

		public ResourceManager()
		{
			resourceAssembly = typeof(ResourceManager).Assembly;
			var resourceNames = resourceAssembly.GetManifestResourceNames();

			torchlightButtonNormal =
				new Bitmap(
					resourceAssembly.GetManifestResourceStream(
						resourceNames.Where(n => n.Contains("TorchlightButtonNormal.png")).First()));

			torchlightButtonHighlight =
				new Bitmap(
					resourceAssembly.GetManifestResourceStream(
						resourceNames.Where(n => n.Contains("TorchlightButtonHighlight.png")).First()));

			torchlightButtonClickHighlight =
				new Bitmap(
					resourceAssembly.GetManifestResourceStream(
						resourceNames.Where(n => n.Contains("TorchlightButtonClickHighlight.png")).First()));

			healDrinkSound = new SoundPlayer(resourceAssembly.GetManifestResourceStream(
						resourceNames.Where(n => n.Contains("healdrink.wav")).First()));			

			healDrinkSound.Load();
			healDrinkSound.Play();
			healDrinkSound.Stop();
		}

		public SoundPlayer HealDrinkSound
		{
			get
			{
				return healDrinkSound;
			}
		}

		public Image TorchlightButtonNormal
		{
			get
			{
				return torchlightButtonNormal;
			}
		}

		public Image TorchlightButtonHighlight
		{
			get
			{
				return torchlightButtonHighlight;
			}
		}

		public Image TorchlightButtonClickHighlight
		{
			get
			{
				return torchlightButtonClickHighlight;
			}
		}
	}
}
